
#include <iostream>
#include <string>
#include <vector>
#include <string.h>
using namespace std;
bool is_lexic(vector<string> str) {
    for (size_t i = 1; i < str.size(); ++i) {
        if (strcmp(&str[i][0], &str[i - 1][0]) < 0)return false;
    }
    return true;
}
bool is_lengs(vector<string>& str) {
    for (size_t i = 1; i < str.size(); ++i) {
        if (str[i].size() < str[i - 1].size())return false;
    }
    return true;
}
int main() {
    int n;
    cin >> n;
    getchar();
    vector<string> vstr;
    vstr.resize(n, "\0");
    for (size_t i = 0; i < n; ++i) {
        getline(cin, vstr[i]);
    }
    if (is_lexic(vstr) && is_lengs(vstr)) {
        cout << "both" << endl;
    }
    else if (is_lengs(vstr)) {
        cout << "lengths" << endl;
    }
    else if (is_lexic(vstr)) {
        cout << "lexicographically" << endl;
    }
    else {
        cout << "none" << endl;
    }
    return 0;
}